home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / music / 213 / pascal / parmtest.pas < prev    next >
Pascal/Delphi Source File  |  1988-01-13  |  2KB  |  87 lines

  1. program
  2. NEWTRY (output);
  3.  
  4.  
  5. { This is a very simple test of functional parameter passing.
  6.   It should work in any pascal dating from after the revision;
  7.   e.g., ISO level 0.  It DOES NOT WORK IN PERSONAL PASCAL!
  8.  
  9.   I attempt to compile the program for TOS.
  10.   The compile goes well, then just before the loading linker message,
  11.   two bombs appear, followed by the link box and then an error box
  12.   indicating READ ERROR IN FILE NEWTRY.
  13.  
  14.   At a meeting of the San Leandro Computer Club last year, I
  15.   mentioned the problem to Mark Rose.  He said that Personal
  16.   Pascal DID allow procedural and functional parameters and that
  17.   I should make sure I was using the new syntax, rather than the
  18.   old J&W syntax.  I was.  I am.  It doesn't work.
  19.  
  20.   I would appreciate an explanation or correction which would allow
  21.   me to use this nice feature of pascal--and I still like you guys;
  22.   when is version two of Personal Pascal going to appear?
  23.  
  24.      Gary Curtis Newport
  25.      27808 Manon Ave. # 18
  26.      Hayward, CA  94544
  27.  
  28.      Phone 415-785-2047
  29.  
  30.      Personal Pascal Reg # P61L199C7264
  31.  
  32. }
  33.  
  34.  
  35.    CONST
  36.  
  37.       pi    = 3.141563;
  38.  
  39.    VAR
  40.  
  41.       x, y  : real;
  42.  
  43.  
  44.  
  45. function x_cos (p:real): real;
  46.  
  47. BEGIN {X_COS}
  48.  
  49. x_cos := cos(p)
  50.  
  51. END; {X_COS}
  52.  
  53.  
  54.  
  55.  
  56. function x_sin (p:real):real;
  57.  
  58. BEGIN {X_SIN}
  59.  
  60. x_sin := sin(p)
  61.  
  62. END; {X_SIN}
  63.  
  64.  
  65.  
  66. function trig( function f(r:real):real; s:real):real;
  67.  
  68. BEGIN {TRIG}
  69.  
  70. trig := f(s)
  71.  
  72. END; {TRIG}
  73.  
  74.  
  75.  
  76. BEGIN {main}
  77.  
  78. writeln('Now testing for  pi/3');
  79. writeln;
  80. y := trig(x_sin, (pi/3));
  81. writeln('sin pi/3 is : ',y);
  82. writeln;
  83. y := trig(x_cos, (pi/3));
  84. writeln('cos pi/3 is : ',y);
  85.  
  86. END. {NEWTRY}
  87.